home *** CD-ROM | disk | FTP | other *** search
/ PD Collection CD 1 / PD Collection CD 1.iso / programer2 / pari2 / pari / other / pari_elc < prev    next >
Text File  |  1991-11-13  |  13KB  |  256 lines

  1.  
  2. (provide (quote gp))
  3.  
  4. (defconst gp-chap3 "~pari/PARISOURCES/tex/usersch3.tex" "\
  5. The TeX source for chapter 3 of the PARI-GP manual")
  6.  
  7. (defconst gp-file-name "/usr/local/bin/gp" "\
  8. The file name of the gp executable file")
  9.  
  10. (defconst gp-man-dvi "~pari/SPARC/tex/users.dvi" "\
  11. dvi version of the manual")
  12.  
  13. (defconst gp-menu "~pari/PARISOURCES/pari.menu" "\
  14. menu file")
  15.  
  16. (defconst gp-dvi-preview "xdvi -s 3" "\
  17. dvi previewer (and options)")
  18.  
  19. (defvar gp-stack-size "4000000" "\
  20. Default stack size: passed to the progam gp.")
  21.  
  22. (defvar gp-buffer-size "30000" "\
  23. Default buffer size: passed to the progam gp.")
  24.  
  25. (defvar gp-prime-limit "500000" "\
  26. Default prime limit: passed to the progam gp.")
  27.  
  28. (defvar gp-prompt-for-args nil "\
  29. A non-nil value makes M-x gp act like C-u M-x gp, 
  30.    ie prompt for the command line arguments.")
  31.  
  32. (defvar gp-prompt-pattern "---- (type return to continue) ----\\|\\?[
  33.      ]*" "Regexp used to match gp prompts.
  34.    can be set with gp-set-prompt (bound to M-\\ p)")
  35.  
  36. (defvar gp-map (make-sparse-keymap) "\
  37. Local keymap used in buffer *PARI*.")
  38.  
  39. (define-key gp-map "" (quote gp-send-input))
  40.  
  41. (define-key gp-map "™" (quote gp-copy-input))
  42.  
  43. (define-key gp-map "Üp" (quote gp-set-prompt))
  44.  
  45. (define-key gp-map "Üt" (quote gp-meta-t))
  46.  
  47. (define-key gp-map "Üd" (quote gp-meta-d))
  48.  
  49. (define-key gp-map "Ür" (quote gp-meta-r))
  50.  
  51. (define-key gp-map "Üw" (quote gp-meta-w))
  52.  
  53. (define-key gp-map "Üv" (quote gp-meta-v))
  54.  
  55. (define-key gp-map "Üx" (quote gp-meta-x))
  56.  
  57. (define-key gp-map "Üs" (quote gp-meta-s))
  58.  
  59. (define-key gp-map "Üb" (quote gp-meta-b))
  60.  
  61. (define-key gp-map "Ük" (quote gp-meta-k))
  62.  
  63. (define-key gp-map "Üq" (quote gp-meta-q))
  64.  
  65. (define-key gp-map "¿" (quote gp-get-man-entry))
  66.  
  67. (define-key gp-map "Üc" (quote gp-menu))
  68.  
  69. (define-key gp-map "Ü\\" (quote gp-break-long-line))
  70.  
  71. (define-key gp-map "" (quote gp-interrupt))
  72.  
  73. (defvar gp-process nil "\
  74. ")
  75.  
  76. (defvar gp-man-process nil "\
  77. ")
  78.  
  79. (defun gp (flag) "\
  80.  
  81.    Open a buffer and a window for the execution of gp.
  82.  
  83.    The following bindings are available:
  84.    \\{gp-map}
  85.  
  86.   The variables
  87.   gp-file-name gp-stack-size gp-buffer-size gp-prime-limit
  88.   determine the command line that starts gp.
  89.   To override the default settings, give gp a prefix argument.
  90.   C-u M-x gp ." (interactive "P") (byte-code "Á⇦ÎÏ!⇦db⇦◰ÁŵnР⇦Ñ⇨⇦Ò⇨⇦ÓÔ!⇦Õ !⇦Ö⇨⇦ŷ/×Ø    Ù$×Ú
  91. Û$×Ü Ý$×Þ ß$RààQc⇦áâÏãäP%⇨*⇦åæ\"" [gp-process nil major-mode mode-name gp-map mode-line-process flag gp-prompt-for-args gp-command gp-file-name gp-stack-size gp-buffer-size gp-prime-limit shell-file-name switch-to-buffer "*PARI*" kill-all-local-variables gp "GP" run-hooks gp-mode-hook use-local-map (": %s") gp-read-input "Gp executable ?" "" "Stack size ?" " -s " "Buffer size ?" " -b " "Prime limit ?" " -p " "
  92. " start-process "pari" "-c" "stty nl; exec " set-process-sentinel gp-sentinel] 15))
  93.  
  94. (defun gp-read-input (prompt default sep flag) "\
  95.  If flag is non-nil, reads string then if string is \"\" uses default.
  96.   If flag is nil then string is the default.
  97.   If resulting string is not \"\" prepends sep.
  98.   As a special case, if string is a space, return \"\"." (byte-code "    ◰Å
  99. Æ ÇR!ŵ ÈÉ\"◰(È É\"◰\"Éŵ% Pŵ6ÈÊ\"◰3Éŵ6 P)" [string flag prompt default sep read-input " (Default " ") " equal "" " "] 6))
  100.  
  101. (defun gp-sentinel (proc msg) "\
  102. Sentinel for the gp-process in buffer *PARI*." (byte-code "ÇÈ!ŶÈq⇦db⇦c⇦ÉÈ!⇦ÇÊ!ŶËÊ!⇦Ì
  103. !    Ŷ(Ë    !)⇦Ì !    Ŷ5Ë    !)⇦Í !ŶGÎÏ P!⇦ÐÑ \"⇦Æ⇨" [msg b gp-chap3 gp-menu gp-temp-file gp-process nil get-buffer "*PARI*" delete-windows-on "*gp-help*" kill-buffer get-file-buffer file-exists-p shell-command "rm " message "Removing %s"] 13))
  104.  
  105. (defun gpman nil "\
  106. Start up xdvi with the gp manual." (interactive) (byte-code "Á⇦ÅÆ!⇦ÇÈ!q⇦◰Áŵ-ÉÊ
  107. Ë R!⇦ÌÍÈ ÎÏ
  108. Ë R%⇨⇦ÐÑ\"" [gp-man-process nil gp-dvi-preview gp-man-dvi shell-file-name run-hooks gp-mode-hook get-buffer-create "*GP-MAN*" message "Starting " " " start-process "gp-man" "-c" "exec " set-process-sentinel gp-man-sentinel] 12))
  109.  
  110. (defun gp-man-sentinel (proc msg) "\
  111. Sentinel for the gp-man-process in buffer *GP-MAN*." (byte-code "Å    !Ŷ Æ!)⇦ÇÈ
  112. P!⇦Ä⇨" [buf proc msg gp-man-process nil process-buffer kill-buffer message "gpman: "] 5))
  113.  
  114. (defun gp-copy-input nil "\
  115. Copy expression around point to the end of the buffer.
  116.    (Unless this is already the last expression.)" (interactive) (byte-code "É⇦Ê!⇦ËÌ!Í ⇦Î!⇦`⇨⇦    b)⇦ÎÏÐQdÄ# ◰,ÑÌ!ŵ-d
  117. b⇦ÒÓ!◰;Ôŵ<ÕÎÖ#⇨⇦`⇨⇦ Ŷjdb⇦×
  118. \"c⇦◰dÉŵjØ ⇦ÙÚ!)))" [gp-prompt-pattern p gp-input-start nlast t limit end-expression gp-complete-expression gp-input-end nil re-search-backward match-end 0 beginning-of-line re-search-forward "[
  119.  ]*\\(" "\\|%[0-9]+ =\\|\\*\\*\\*\\|unused characters\\|time\\)" match-beginning looking-at " *{" "}$" "[^\\]$" 1 buffer-substring ding message "Incomplete expression."] 12))
  120.  
  121. (setq gp-temp-file (make-temp-name "/usr/tmp/gp_"))
  122.  
  123. (defun gp-send-input nil "\
  124. Send input to gp. Does not send incomplete expressions
  125.    ie those starting with {, without a matching }, or those
  126.    ending with \\ .
  127.    Use a temporary file (and \\r ) for large expressions" (interactive) (byte-code "Å⇦Æ ⇦Çc⇦◰8    
  128. ZÈV◰$É
  129.      #⇦Ê Ë ÇQ\"ŵ.Ì
  130.     #⇦Ê Ç\"⇦ÍÎ !`\"ŵ;ÏÐ!" [gp-complete-expression gp-input-end gp-input-start gp-temp-file gp-process nil gp-copy-input "
  131. " 255 write-region process-send-string "\\r " process-send-region set-marker process-mark message "Incomplete expression: Not sent to gp."] 9))
  132.  
  133. (defun gp-interrupt nil "\
  134. Interrupt gp.
  135.    This is identical to interrupt-shell-subjob in shell-mode." (interactive) (byte-code "À⇦ÂÀÁ\"" [nil t interrupt-process] 3))
  136.  
  137. (defun gp-set-prompt (p) "\
  138. Set new gp prompt (and tell emacs that you have done so).
  139.    Do not put spaces in the argument, or emacs and gp will
  140.    have a different idea about what the prompt is." (interactive "sNew prompt: ") (byte-code "Â⇦à   !ÄQ⇨⇦Åq⇦db⇦Æ    Pc⇦Ç " [gp-prompt-pattern p nil regexp-quote "[
  141.      ]*\\|" "*PARI*" "\\prompt=" gp-send-input] 4))
  142.  
  143. (defun gp-replace (a b) "\
  144. Replace the regexp a by the string b everywhere in the current buffer" (byte-code "eb⇦ÃdÁ#ŶÄ
  145. ÁÁ#⇦ŵ" [a t b re-search-forward replace-match] 6))
  146.  
  147. (defun gp-get-man-entry (fn) "\
  148. Obtains the description of fn from chapter 3 of the manual.
  149.   Strips off some (not all) of the TeX syntax, and displays the result
  150.   in a new window.
  151.   If there is no entry for fn in the manual, sends ?fn to gp." (interactive "sFunction: ") (byte-code "Á⇦ÁÈ
  152. !q)⇦É Ê\"◰Ëŵ·É Ì\"◰ Íŵ·É Î\"◰+Ïŵ·É Ð\"◰6Ñŵ·É Ò\"◰AÓŵ·É Ô\"◰LÕŵ·É Ö\"◰W×ŵ·É Ø\"◰bÙŵ·É Ú\"◰mÛŵ·É Ü\"◰xÝŵ·É Þ\"ŷ­É ß\"ŷ­É à\"ŷ­É á\"ŷ­É â\"ŷ­É ã\"ŷ­É ä\"ŷ­É å\"◰´æŵ·ç !eb⇦èé êQdÅ#◰ëì!b⇦í`èîdÅ#⇦ïð!\"ñ òóô!!⇦õ ⇦c⇦ö÷Ô\"⇦öøù\"⇦öËÊ\"⇦öúÌ\"⇦öûü\"⇦eb⇦ý!*ŵþq⇦ÿŴ@ P!)" [auto-mode-alist nil gp-chap3 qfn fn t copy wind find-file-noselect equal "\\" "\\\\backslash" "^" "\\\\hat{}" "!" "fact" "~" "trans" "_" "conj" "-" "\\+" "%" "\\\\%" "min" "max" "log" "ln" "det2" "det" "<=" "<" ">=" ">" "==" "!=" "||" "&&" "comparison and \\\\ref{boolean operators}" regexp-quote re-search-forward "\\(subsec[\\\\{ref]*[\\${]\\)" "[}\\$]" match-end 1 buffer-substring "[tT]he library\\|\\\\[sub]*sec" match-beginning 0 selected-window switch-to-buffer-other-window get-buffer-create "*gp-help*" erase-buffer gp-replace "\\$-" "\\$" " " "\\\\hat" "\\\\smallskip\\|\\\\sref{[ a-z]*}\\|\\\\bf\\|\\\\ref\\|\\\\Bbb\\|\\\\text\\|\\\\tt\\|{\\|}" "" select-window "*PARI*" gp-meta-command "?"] 39))
  153.  
  154. (defun gp-meta-command (command) "\
  155. Send command to gp, and display output in help buffer" (byte-code "db⇦`Å Æ
  156. ÇP\"⇦È ⇦Éd\"Êd\"⇦ËÌÍ!!⇦Π⇦ c⇦Ï ⇦Ê`d\"⇦eb⇦Р   !)*" [temp wind gp-process command copy selected-window process-send-string "
  157. " gp-wait-for-output buffer-substring delete-region switch-to-buffer-other-window get-buffer-create "*gp-help*" erase-buffer beginning-of-line select-window] 12))
  158.  
  159. (defun gp-wait-for-output nil "\
  160. Hang around until the prompt appears." (byte-code "Á⇨⇦Ŷ,ÅÆ!⇦`Ç ⇦È !◰!ÉÊ!⇦Ä⇨ŵ$ÉË!⇦
  161. b)⇦ŵ" [ndone t p gp-prompt-pattern nil accept-process-output "*PARI*" beginning-of-line looking-at message "done" "Waiting for gp output ..."] 7))
  162.  
  163. (defun gp-meta-d nil "\
  164. Sends \\d to gp, then displays output in the help buffer.
  165.   Prints the gp defaults." (interactive) (byte-code "À⇦ÁÂ!" [nil gp-meta-command "\\d"] 2))
  166.  
  167. (defun gp-meta-t nil "\
  168. Sends \\t to gp, then displays output in the help buffer.
  169.   Prints the longword format of PARI types." (interactive) (byte-code "À⇦ÁÂ!" [nil gp-meta-command "\\t"] 2))
  170.  
  171. (defun gp-meta-r (file) "\
  172. Sends a \\r <file name> comand to gp.
  173.    Reads in gp commands from a file.
  174.    See gp-meta-r" (interactive "fRead from file: ") (byte-code "Á⇦db⇦ÂÃ!Pc⇦Ä " [file nil "\\r " expand-file-name gp-send-input] 3))
  175.  
  176. (defun gp-meta-w (file num) "\
  177. Sends a \\w<num> <file name> comand to gp.
  178.   Writes gp object %<num> to <file name>." (interactive "FWrite to file: 
  179. sObject number %%") (byte-code "Â⇦db⇦ÃÄÅ    !Rc⇦Æ " [num file nil "\\w" " " expand-file-name gp-send-input] 5))
  180.  
  181. (defun gp-meta-x nil "\
  182. Sends \\x to gp, then displays output in the help buffer.
  183.   Prints tree of addresses and contents of last object." (interactive) (byte-code "À⇦ÁÂ!" [nil gp-meta-command "\\x"] 2))
  184.  
  185. (defun gp-meta-v nil "\
  186. Sends \\v to gp, then displays output in the help buffer.
  187.   Prints the version number of this implementation of pari-gp." (interactive) (byte-code "À⇦ÁÂ!" [nil gp-meta-command "\\v"] 2))
  188.  
  189. (defun gp-meta-s (num) "\
  190. Sends \\s or \\s(num) to gp, then displays output in the help buffer.
  191.   Prints the state of the pari stack." (interactive "sNumber of longwords (default 0) ") (byte-code "Á⇦ÂÃ\"◰ÄÅ!ŵÄÆÇQ!" [num nil equal "" gp-meta-command "\\s" "\\s(" ")"] 6))
  192.  
  193. (defun gp-meta-b (num) "\
  194. Sends \\b or \\b<num> to gp, then displays output in the help buffer.
  195.   Prints object %<num> in pretty format (unless \\p set)." (interactive "sPrint object (default last) %%") (byte-code "Á⇦ÂÃ\"◰ÄÅ!ŵÄÅP!" [num nil equal "" gp-meta-command "\\b"] 5))
  196.  
  197. (defun gp-meta-k nil "\
  198. Sends \\k to gp.
  199.   Prompts for confirmation before 
  200.   re-initialising gp and clearing the buffer." (interactive) (byte-code "Á⇦ÂÃ!Ŷ%Äq⇦db⇦Åc⇦ÆÇ!`\"⇦ÂÈ!Ŷ É ⇦ÊÅ\"⇦ËÌ!" [gp-process nil y-or-n-p "Re-initialise gp ? " "*PARI*" "\\k
  201. " set-marker process-mark "Clear *PARI* buffer ? " erase-buffer process-send-string message ""] 8))
  202.  
  203. (defun gp-meta-q nil "\
  204. Sends \\q to gp.
  205.   Prompts for confirmation before quiting." (interactive) (byte-code "Á⇦ÂÃ!ŶÄq⇦db⇦ÅÆ\"⇦ÇÈ!" [gp-process nil y-or-n-p "Quit gp ? " "*PARI*" process-send-string "\\q
  206. " message ""] 4))
  207.  
  208. (defun gp-break-long-line nil "\
  209. gp will not accept lines longer than 256.
  210.    gp-break-long-lines breaks current line 
  211.    inserting \\ every 100 chars." (interactive) (byte-code "À⇦Á ⇦ÂÃ!⇦ÄÅ!?ŶÆc⇦ÂÃ!⇦ŵ    " [nil beginning-of-line move-to-column 100 looking-at "$" "\\
  212. "] 6))
  213.  
  214. (defun gp-menu nil "\
  215. Major-mode for the gp menu buffer.
  216. The available commands are
  217. \\{gp-menu-map}" (interactive) (byte-code "Æ⇦Ç!⇦Â⇨⇦È ⇦À⇨⇦É⇨⇦Ê!⇦Ë " [gp-menu buffer-read-only t major-mode mode-name gp-menu-map nil find-file-other-window kill-all-local-variables "GP MENU" use-local-map gp-menu-main] 5))
  218.  
  219. (defun gp-menu-info nil (byte-code "ÀÁ!" [message "SPC=next DEL=previous RET=select m=main-menu q=quit s=scroll-help"] 2))
  220.  
  221. (defun gp-menu-next nil "\
  222. Move down one line of the gp help menu. (Go to top if at the end.)" (interactive) (byte-code "À⇦Á ⇦ÂÃ!⇦mŶÄ ⇦eb" [nil gp-menu-info forward-line 1 ding] 4))
  223.  
  224. (defun gp-menu-previous nil "\
  225. Move up one line of the gp help menu. (Go to bottom if at the top.)" (interactive) (byte-code "À⇦Á ⇦o◰ ⇦db⇦àŵÄÅ!" [nil gp-menu-info ding beginning-of-line forward-line -1] 5))
  226.  
  227. (defun gp-menu-quit nil "\
  228. Switch the *PARI* buffer if it exists, or (other-buffer) if it does not." (interactive) (byte-code "Ã⇦ÄÅ!ÆÅ!◰Ç ⇦È!ŵ%    ◰!É    !ŵ%ÉÊ !*" [w b t nil get-buffer-window "*PARI*" get-buffer delete-window select-window switch-to-buffer other-buffer] 8))
  229.  
  230. (defun gp-menu-select nil "\
  231. Select a subject from the main menu, or a manual entry from a subject menu." (interactive) (byte-code "Á⇦◰3Á⇨⇦à⇦Ä ⇦Å`Æ ⇦`\"ÇÈÉ
  232. P!⇦ÊË!⇦`ÈÌ!⇦ÍÎ!\")⇦ebŵ?Ä ⇦ÏÅ`Æ ⇦`\"!⇦Р" [main-menu nil sect widen beginning-of-line buffer-substring end-of-line narrow-to-region re-search-forward "^###" forward-line 1 "
  233. ###" match-beginning 0 gp-get-man-entry gp-menu-info] 15))
  234.  
  235. (defun gp-menu-main nil "\
  236. Display the main menu." (interactive) (byte-code "Á⇦Ä ⇦Å ⇦eb⇦Æ`ÇÈ!⇦ÉÊ!\"⇦eb⇦Á⇨⇦Ã⇨" [done nil main-menu t gp-menu-info widen narrow-to-region re-search-forward "
  237. ###" match-beginning 0] 7))
  238.  
  239. (defun gp-menu-scroll nil "\
  240. Scroll the gp help window if it is visible" (interactive) (byte-code "Á⇦ ⇦ÃÄ!Ŷ$Å ÆÄ!⇦Çd!◰ebŵÈ ⇦É!)" [wind nil gp-menu-info get-buffer-window "*gp-help*" selected-window switch-to-buffer-other-window pos-visible-in-window-p scroll-up select-window] 8))
  241.  
  242. (defvar gp-menu-map (make-sparse-keymap) "\
  243. Local keymap used in gp menu buffer.")
  244.  
  245. (define-key gp-menu-map " " (quote gp-menu-next))
  246.  
  247. (define-key gp-menu-map "" (quote gp-menu-previous))
  248.  
  249. (define-key gp-menu-map "" (quote gp-menu-select))
  250.  
  251. (define-key gp-menu-map "q" (quote gp-menu-quit))
  252.  
  253. (define-key gp-menu-map "m" (quote gp-menu-main))
  254.  
  255. (define-key gp-menu-map "s" (quote gp-menu-scroll))
  256.